package com.zoke.dappstore.adapter;

import android.support.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.zoke.dappstore.R;
import com.zoke.dappstore.model.Comment;
import com.zoke.dappstore.tools.Tools;

import java.util.List;

import me.zhanghai.android.materialratingbar.MaterialRatingBar;

/**
 * Created by wulijie on 2018/6/11.
 */
public class CommentAdapter extends BaseQuickAdapter<Comment, BaseViewHolder> {
    public CommentAdapter(@Nullable List<Comment> data) {
        super(R.layout.item_comment, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, Comment item) {
        MaterialRatingBar rb = helper.getView(R.id.rb);
        helper.setText(R.id.tv_comment, item.content)
                .setText(R.id.tv_name, "评论人：" + item.author)
                .setText(R.id.tv_address, "评论地址：" + item.authorAddress)
                .setText(R.id.tv_time, "评论时间：" + Tools.formatTime(item.updateTime));
        rb.setProgress(item.score * 2);
        rb.setIsIndicator(false);
    }
}
